$(function () {
    var cutomerDrain_datagrid = $("#cutomerDrain_datagrid");
    var cutomerDrain_form = $("#cutomerDrain_form");
    cutomerDrain_datagrid.datagrid({
        url: '/cutomerDrain/list.do',
        fitColumns: true,
        fit: true,
        pagination: true,    //分页条
        rownumbers: true,     //行号列
        singleSelect: true,
        toolbar: '#tb',
        columns: [[
            {field: 'customer', title: '客户名称', width: 100,formatter:function (value) {
                return value ? value.name : "";
            }},
            {field: 'transTime', title: '日期', width: 100},
            {field: 'inChargeUser', title: '当前负责人', width: 100,formatter:function (value) {
                return value ? value.username : "";
            }},
            {field: 'reason', title: '移交原因', width: 100}
        ]]
    })

    var methodObj = {
        reload: function () {
            cutomerDrain_datagrid.datagrid('reload');
        },
        query: function () {
            var beginTime = $("[name=beginTime]").val();
            var endTime = $("[name=endTime]").val();
            var clientName = $("[name=clientName]").val();
            var chargeUserName = $("[name=chargeUserName]").val();
            cutomerDrain_datagrid.datagrid('load', {
                beginTime: beginTime,
                endTime: endTime,
                clientName: clientName,
                chargeUserName: chargeUserName
            })
        }
    }
    $("a[data-cmd]").click(function () {
        //获取按钮上的data-cmd的值
        var methodName = $(this).data("cmd");
        methodObj[methodName]();
    })
})
